<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Dcat\Admin\Admin;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Illuminate\Support\Facades\Cache;

class HomeController extends Controller {
	public function index(Content $content) {
		return $content
			->header('欢迎登录，' . Admin::user()->name)
			->description('上次登录时间：' . date("Y-m-d H:i:s", Admin::user()->login_time) . '，上次登录IP: ' . Admin::user()->login_ip)
			->body(function (Row $row) {
				//如果不需要统计信息，注释一线内容

				// $row->column(8, function (Column $column) {
				// 	$column->row(new Examples\NewUsers());
				// });

				// $row->column(12, function (Column $column) {

				// 	$column->row(function (Row $row) {
				// 		$row->column(3, new Charts\Counter());
				// 		$row->column(3, new Charts\Counter());
				// 		$row->column(3, new Charts\Counter());
				// 		$row->column(3, new Charts\Counter());
				// 	});
				// 	$column->row(new Charts\Order());
				// });
			});
	}
	public function cacheFlush() {
		Cache::flush();
		return response()
			->json(['code' => 1, 'msg' => '缓存已更新']);
	}
}
